from PySide2.QtWidgets import QApplication, QMainWindow, QMessageBox, QPushButton,  QPlainTextEdit

def handleCalc():
    info = textEdit.toPlainText()

    salary_above_20k = ''
    salary_below_20k = ''

    for line in info.splitlines():  # 分行
        if not line.strip():    
            continue
        parts = line.split(' ')
        parts = [p for p in parts if p]
        name, salary, age = parts
        if int(salary) >= 20000:
            salary_above_20k += name + '\n'
        else:
            salary_below_20k += name + '\n'
    
    QMessageBox.about(window, '统计结果', 
                      f'''薪资20000以上有: \n{salary_above_20k}\n薪资20000以下有: \n{salary_below_20k}''')

# QApplication 提供了整个图形界面的底层管理功能
app = QApplication([])

# 创建一个主窗口对象
window = QMainWindow()
# 控制主窗口的大小
window.resize(500, 400)
# 主窗口启动后左上角在启动器的位置
window.move(300, 310)
# 窗口标题
window.setWindowTitle('薪资统计')

# 文本编辑框
textEdit = QPlainTextEdit(window)
textEdit.setPlaceholderText("请输入薪资表")
textEdit.move(10,25)
textEdit.resize(300,350)

button = QPushButton('统计', window)
button.move(380,80)
# handleCalc是一个slot
button.clicked.connect(handleCalc)

window.show()

app.exec_()